#ifndef __24CXX_H
#define __24CXX_H

#include "main.h"
#include "stdio.h"


#define USE_SOFTWARE_I2C				1


#if USE_SOFTWARE_I2C==1

#define AT24CXX_SCL_GPIO_PORT 			GPIOB
#define AT24CXX_SCL_GPIO_PIN			GPIO_PIN_14

#define AT24CXX_SDA_GPIO_PORT 			GPIOB
#define AT24CXX_SDA_GPIO_PIN			GPIO_PIN_15

#define AT24CXX_I2C_DELAY				10
#define AT24CXX_I2C_TIMEOUT				2000
#else
#define AT24CXX_I2C_HANDLE				hi2c1
extern 	I2C_HandleTypeDef 				AT24CXX_I2C_HANDLE;
#endif



//器件地址，函数中已经区分读和写地址(软件i2c和硬件i2c),最后1位为读写标志位,高为读,低为写
#define AT24CXX_ADDR					0xA0

#define AT24CXX_TYPE 					AT24C256
#define AT24CXX_PAGE_SIZE 				64
/*
 * 24C01 	PageSize  8
 * 24C02 	PageSize  8
 * 24C04 	PageSize  16
 * 24C08  	PageSize  16
 * 24C16  	PageSize  16
 * 24C32 	PageSize  32
 * 24C64  	PageSize  32
 * 24C128  	PageSize  64
 * 24C256  	PageSize  64
*/

#define AT24C01 			127
#define AT24C02 			255
#define AT24C04 			511
#define AT24C08 			1023
#define AT24C16 			2047
#define AT24C32 			4095
#define AT24C64 			8191
#define AT24C128 			16383
#define AT24C256 			32767




uint8_t AT24CXX_WriteData(uint16_t MemAddress,uint8_t *data,int size);
uint8_t AT24CXX_ReadData(uint16_t MemAddress,uint8_t *buff,int size);
uint8_t AT24CXX_Test();


#endif
